package com.zhou.common.model.response;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;

@Data
@ToString
@EqualsAndHashCode(callSuper = true)
public class QueryResponseResult<T> extends ResponseResult {

    QueryResult<T> queryResult;

    public QueryResponseResult(ResultCode resultCode,QueryResult<T> queryResult){
        super(resultCode);
       this.queryResult = queryResult;
    }

    public static <T> QueryResponseResult<T> success(QueryResult<T> queryResult){
        return new QueryResponseResult<>(CommonCode.SUCCESS, queryResult);
    }

    /**
     * 数据查询相应结果
     * @author Hao.
     * @date 2020/6/9 18:32
     * @param list 结果集
     * @param total 结果数量
     * @return com.xuecheng.framework.model.response.QueryResponseResult
     */
    public static <T> QueryResponseResult<T> success(List<T> list, long total){
        return QueryResponseResult.success(QueryResult.get(list, total));
    }

    public static QueryResponseResult fail(){
        return ( QueryResponseResult) ResponseResult.fail();
    }

    public static QueryResponseResult fail(String msg){
        return (QueryResponseResult) ResponseResult.fail(msg);
    }
}
